//
//  MainViewController.m
//  WeiboOC
//
//  Created by yang on 15/11/11.
//  Copyright © 2015年 yang. All rights reserved.
//

#import "MainViewController.h"

@interface MainViewController ()

@end

@implementation MainViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    YQTabBar * tab = [[YQTabBar alloc]init];
    [tab.button addTarget:self action:@selector(didClickButton) forControlEvents:UIControlEventTouchUpInside];
    UITabBar *mainTabBar = tab;
    [self setValue:mainTabBar forKey:@"tabBar"];
    [self setupUI];
}
- (void)didClickButton{
    NSLog(@"__func__");
}
- (void)setupUI{
    YQHomeTableViewController* home = [[YQHomeTableViewController alloc] init];
    YQMessageTableViewController* message = [[YQMessageTableViewController alloc] init];
    YQDiscoverTableViewController* discover = [[YQDiscoverTableViewController alloc] init];
    YQProfileTableViewController* profile = [[YQProfileTableViewController alloc] init];
    [self addChildViewController:home titleString:@"主页" imageName:@"tabbar_home"];
    [self addChildViewController:message titleString:@"消息" imageName:@"tabbar_message_center"];
    [self addChildViewController:discover titleString:@"发现" imageName:@"tabbar_discover"];
    [self addChildViewController:profile titleString:@"我" imageName:@"tabbar_profile"];
}
- (void)addChildViewController:(UIViewController*)controller titleString:(NSString*)title imageName:(NSString*)imageName
{
    UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:controller];
    controller.title = title;
    controller.tabBarItem.image = [UIImage imageNamed:imageName];
    NSString* selImageName = [NSString stringWithFormat:@"%@_highlighted", imageName];
    controller.tabBarItem.selectedImage = [[UIImage imageNamed:selImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [self addChildViewController:nav];
}
@end
